<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加住院病人</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
  <script src="../../../bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
            <td valign="bottom" class="title">添加病人医嘱</td>
          </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="">
<table width="95%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="90" align="center" class="td_form01">选择科室</td>
    <td colspan="3" class="td_form02"> <select name="depid">
    </select></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">主治医生</td>
    <td colspan="3" class="td_form02"> <select name="staid">
    </select></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">病人姓名</td>
    <td colspan="3" class="td_form02"> <select name="pid">
  </select></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">开始时间</td>
    <td colspan="3" class="td_form02"><input name="startdate" type="date" class="input"></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">结束时间</td>
    <td colspan="3" class="td_form02"><input name="terminationdate" type="date" class="input"></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">医嘱</td>
    <td colspan="3" class="td_form02"><input name="doccontent" type="text" class="input"></td>
  </tr>

</table>
  <br>
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center"><input name="Submit" type="submit" class="buttonface" value="  增加  ">
        <input name="Submit" type="submit" class="buttonface" onClick="window.close()" value="  关闭  "></td>
    </tr>
  </table>
  </form>
</center>
<script>
  function f() {
    $.ajax({
      url: "/feign/book/getdeparement",
      type: "get",
      dataType: "json",
      headers: {
        Accept: "application/json; charset=utf-8",
        Authorization: location.href.split("=")[1]
      },
      success: function (data) {
        $.each(data.data,function (index,data) {
          $("select[name='depid']").append("<option value='" + data.depid + "'>" + data.depname + "</option>"),
                  fun1()
        })

      }
    })
  }


  function fun1() {
    $("select[name='depid']").change(function () {
      var depid = $("select[name='depid']").val();
      $.ajax({
        url: "/feign/book/displayStaffByDepartment",
        type: "get",
        dataType: "json",
        headers: {
          Accept: "application/json; charset=utf-8",
          Authorization: location.href.split("=")[1]
        },
        data: {"depid": depid,
          "posid":1,
        },
        success: function (data) {
          $.each(data.data,function (index,data) {
            $("select[name='satid1']").append("<option value='" + data.staffid + "'>" + data.staname + "</option>")
          })
        }
      })
      $.ajax({
        url: "/feign/book/displayAll",
        type: "get",
        dataType: "json",
        headers: {
          Accept: "application/json; charset=utf-8",
          Authorization: location.href.split("=")[1]
        },
        data: {"depid": depid

        },
        success: function (data) {
          $.each(data.data,function (index,data) {
            $("select[name='satid2']").append("<option value='" + data.pid + "'>" + data.pname + "</option>")
          })
        }
      })
    })


    $("input[name='submit']").on("click",function () {
      $.ajax({
        url:"/feign/book/insertInpatientMessage",
        type:"post",
        headers: {
          Accept: "application/json; charset=utf-8",
          Authorization: location.href.split("=")[1]
        },
        data:$("form").serialize(),
        dataType:"json",
        success:function (data) {
          alert(data.msg)
          if (data.code==200){
            alert(data.msg);
          }
        }
      })

    })
  }
</script>
</body>
</html>
